import os
import cv2
import utils
from tqdm import tqdm

path_yuv420sp = r'/media/fang/3441-913C/tsr/img/src'
path_output = path_yuv420sp
w = 1920
h = 1080
# if path_yuv420sp.split("_")[0] == "d3":
#     w = 300
#     h = 300


for root, dirs, files in os.walk(path_yuv420sp):
    for file in tqdm(files):
        if file.split(".")[-1] == 'yuv420sp':
            if file.split("_")[0] == "d3":
                bgr = utils.yuv420sp2bgr(root + '/' + file, 300, h)
            else:
                bgr = utils.yuv420sp2bgr(root + '/' + file, w, h)
            cv2.imwrite(path_output + '/' + file[:-8] + 'jpg', bgr)
